package com.futureCloudMOM.controller.core.web.wms;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.futureCloudMOM.common.core.domain.AjaxResult;
import com.futureCloudMOM.common.core.page.TableDataInfo;
import com.futureCloudMOM.common.utils.core.QueryWapperDTO;
import com.futureCloudMOM.common.utils.core.QueryWapperUtils;
import com.futureCloudMOM.controller.core.controller.BaseApiController;
import com.futureCloudMOM.core.domain.WmsErpSourceMain;
import com.futureCloudMOM.core.service.WmsErpSourceMainService;
import com.futureCloudMOM.core.view.VWmsErplistview;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 文件名 WmsErpSourceMainController
 *
 * @since 2023/6/7 9:15
 */
@Api(tags = "源单主表")
@RestController
@RequestMapping("wms/erp/source_main")
public class WmsErpSourceMainController extends BaseApiController<WmsErpSourceMain, WmsErpSourceMain, WmsErpSourceMainService> {

    public WmsErpSourceMainController(WmsErpSourceMainService service) {
        super(service);
    }

    @ApiOperation(value = "列表页方法重写,从视图 v_wms_ERPListView 中获取数据")
    @PostMapping("/getListByVO")
    public TableDataInfo getList(VWmsErplistview vWmsErplistview, @RequestBody(required = false) List<QueryWapperDTO> list) {
        startPage();
        QueryWrapper<VWmsErplistview> queryWrapper = QueryWapperUtils.wapperJojnt(vWmsErplistview, list);
        queryWrapper.orderByDesc("billcreatedate");
        return getDataTable(service.getList(queryWrapper));
    }

    @ApiOperation(value = "源单主子表信息新增")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody WmsErpSourceMain wmsErpSourceMain) {
        return AjaxResult.success(service.add(wmsErpSourceMain));
    }

    @ApiOperation(value = "源单主子表信息保存")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody WmsErpSourceMain wmsErpSourceMain) {
        service.edit(wmsErpSourceMain);
        return AjaxResult.success();
    }


}
